//
//  MoodDetViewController.m
//  YaDiuDiu
//
//  Created by 欧洪飞 on 2017/9/27.
//  Copyright © 2017年 jy. All rights reserved.
//

#import "MoodDetViewController.h"

@interface MoodDetViewController ()<UITableViewDelegate,UITableViewDataSource>{
    NSArray *arr;
}
@property (nonatomic,strong)UITableView *tableView;
@property (nonatomic,strong)NSDictionary *dic;

@end

@implementation MoodDetViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self setBGColor];
    [self showNav:@"商品详情"];
    
    [self loadUI];
    [self loadData];
}

- (void)loadUI{
    UIView *footView = [[UIView alloc] initWithFrame:CGRectMake(0, ScreenHeight-50, ScreenWidth, 50)];
    [self.view addSubview:footView];
    
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.backgroundColor = [UIColor redColor];
    btn.frame = CGRectMake(ScreenWidth/3*2, 0, ScreenWidth/3, 50);
    [btn setTitle:@"立即抢购" forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    btn.titleLabel.font = [UIFont systemFontOfSize:18.0];
    
    [footView addSubview:btn];
    
    UILabel *lab1 = [[UILabel alloc] init];
    lab1.text = @"秒杀价";
    lab1.textColor = [UIColor redColor];
    lab1.font = [UIFont fontWithName:@"Arial-BoldItalicMT" size:17.0];
    [footView addSubview:lab1];
    [lab1 makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(footView.left).offset(16);
        make.top.equalTo(footView.top).offset(8);
    }];
    
    UILabel *lab1Price = [[UILabel alloc] init];
    lab1Price.text = @"$231";
    lab1Price.textColor = [UIColor redColor];
    [footView addSubview:lab1Price];
    [lab1Price makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lab1.right).offset(8);
        make.centerY.equalTo(lab1.centerY);
    }];
    
    UILabel *lab2 = [[UILabel alloc] init];
    lab2.textColor = [UIColor darkGrayColor];
    lab2.text = @"原价";
    [footView addSubview:lab2];
    [lab2 makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lab1.left);
        make.top.equalTo(lab1.bottom).offset(8);
    }];
    
    UILabel *lab2Price = [[UILabel alloc] init];
    lab2Price.textColor = [UIColor darkGrayColor];
    lab2Price.text = @"23123";
    [footView addSubview:lab2Price];
    [lab2Price makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(lab2.right).offset(8);
        make.centerY.equalTo(lab2.centerY);
    }];
    
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, ScreenWidth, ScreenHeight-64-50) style:UITableViewStylePlain];
    _tableView.dataSource = self;
    _tableView.delegate = self;
    [self.view addSubview:_tableView];
    
}
//
- (void)clickPay{
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return arr.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellId = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
    }
    
    cell.textLabel.textColor = arr[indexPath.row];
    
    return cell;
}

//详情
- (void)loadData{
    NSMutableDictionary *parmas = [NSMutableDictionary dictionary];
    [parmas setObject:_mid forKey:@"goods_id"];
    NSString *url = [NSString stringWithFormat:@"%@/App/Seckill/goodsDetails",urlHead];
    [[AFHTTPSessionManager manager] POST:url parameters:parmas success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"res:%@",responseObject);
        _dic = [responseObject objectForKey:@"content"];
        
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        NSLog(@"error:%@",error);
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
